package br.com.devmedia.testes;

import java.util.Calendar;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import br.com.devmedia.beans.Funcionario;
import br.com.devmedia.beans.Grupo;
import br.com.devmedia.beans.Setor;

public class TesteInserirFuncionario {

	public static void main(String[] args) {
		EntityManagerFactory factory = Persistence.createEntityManagerFactory("projetojsf");
		EntityManager manager = factory.createEntityManager();
		
		Grupo grupo = manager.find(Grupo.class, 2);
		Setor setor = manager.find(Setor.class, 2);
		
		
		Funcionario f = new Funcionario();
		f.setAtivo(true);
		f.setCpf("572.429.286-64");
		f.setEmail("ricardo@gmail.com");
		f.setGrupo(grupo);
		f.setNascimento(Calendar.getInstance());		
		f.setNome("Ricardo");
		f.setNomeUsuario("ricardo");
		f.setSalario(2100.00);
		f.setSenha("123456");
		f.setSetor(setor);
		
		manager.getTransaction().begin();
		manager.persist(f);
		manager.getTransaction().commit();
		
		manager.close();
		factory.close();

	}
}
